package com.ice.body.log.controller;

import com.github.pagehelper.PageHelper;
import com.ice.base.controller.BaseController;
import com.ice.base.result.AjaxResult;
import com.ice.base.result.ResponseResult;
import com.ice.body.log.model.LogDestroy;
import com.ice.body.log.service.LogDestroyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * Created with GuoYanBin.
 * Description:
 * Date: 2022-11-15
 * Time: 02:00
 */
@RestController
@Api(tags = "试剂销毁")
public class LogDestroyController extends BaseController{
    //---------------------------试剂销毁-----------------------start
    @Resource
    private LogDestroyService destroyLogService;


 /*   @ApiOperation(value = "试剂销毁-删除")
    @PostMapping("/api/DestroyLog/deleteById")
    public AjaxResult<LogDestroy> deleteById_DestroyLog(@RequestParam("id") String id) {
        AjaxResult r = ResponseResult.success();
        try{
            destroyLogService.delete(id);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }
*/
  /*  @ApiOperation(value = "试剂销毁-更新")
    @PostMapping("/api/DestroyLog/updateById")
    public Result<DestroyLogModel> update_DestroyLog(DestroyLogModel model) {
        Result r = ResponseResult.success();
        try{
            Integer count = destroyLogService.update(model);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }
*/
    @ApiOperation(value = "试剂销毁-查询一个")
    @PostMapping("/api/DestroyLog/selectById")
    public AjaxResult<LogDestroy> selectById_DestroyLog(@RequestParam("id") String id) {
        AjaxResult r = ResponseResult.success();
        try{
           LogDestroy model = destroyLogService.selectById(id);
           r.setData(model);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }

   /* @ApiOperation(value = "试剂销毁-查询多个")
    @PostMapping("/api/DestroyLog/selectAll")
    public Result<DestroyLogModel> selectList_DestroyLog(DestroyLogModel model) {
        Result r = ResponseResult.success();
        try{
           List<DestroyLogModel> list = destroyLogService.selectListByModel(model);
           r.setData(list);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }*/

    @ApiOperation(value = "试剂销毁-查询分页")
    @PostMapping("/api/DestroyLog/selectListByPageHelper")
    public AjaxResult<LogDestroy> selectListByPageHelper_DestroyLog(@RequestParam(name = "pageSize") Integer pageSize,
                                                                    @RequestParam(name = "pageNum") Integer pageNum,
                                                                    LogDestroy model){
        AjaxResult r = ResponseResult.success();
        ArrayList list;
        try{
           PageHelper.startPage(pageNum, pageSize);
           list = destroyLogService.selectListByModel(model);
           getReturnResultByPage(r,list);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }
    //---------------------------试剂销毁-----------------------end

}
